package com.xxx.jsonrpc;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.googlecode.jsonrpc4j.JsonRpcServer;

/**
 * JsonRpc server端（这里是一个servlet）
 */
public class JsonRpcServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1602724573589857128L;
	
	private JsonRpcServer jsonRpcServer = null; // jsonRpcServer

	public JsonRpcServlet() {
		super();
		jsonRpcServer = new JsonRpcServer(new DemoServiceImpl(), DemoService.class);
	}

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		jsonRpcServer.handle(request, response);
	}

}
